home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / H191.ZIP / CA29-3.EXE / BBSETUP.CMD < prev    next >
OS/2 REXX Batch file  |  1993-04-14  |  30KB  |  999 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "BBS Setup ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND BBS setup script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This script, named BBSETUP.CMD, is executed to setup the BBS
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies (and creates) the subdirs to be
  12. ;    used.  The script BBMAINT is used to update related files.
  13. ; -----------------------------------------------------------------------
  14. ;    NOTE: This script expects to find a file named BBSDAT on 1) the
  15. ;    current subdirectory, 2) The COM-AND= environment var specified
  16. ;    subdirectory, or 3) the subdirectory where THIS script resides.
  17. ;    If this file is found, it will be overwritten subsequently.  If
  18. ;    NOT found, BBSDAT will be created on the subdir where COM-AND=
  19. ;    points.  S29 is used to keep the file name (subroutine INIT).
  20. ; -----------------------------------------------------------------------
  21. ;
  22. ;    Establish a DWINDOW, and change the text display to window default.
  23. ;    .. Save the previous text display attribute, for restoration later.
  24. ;
  25.     DWIND 1,2 22,78     ; Establish scrolling region
  26.     N99 = "_TEXT"           ; Save original text attr
  27.     SET TEXT "_DEFA"        ; Set text attr
  28.     SET FLAG(9) OFF     ; Note if we did any saves
  29. ;
  30. ;    Perform tasks
  31. ;
  32.     GOSUB Init        ; Setup initial values
  33.     GOSUB Main        ; Paint main screen
  34. ;***    GOSUB ChkSave        ; Check if save needed
  35.     GOSUB ChkAll        ; Check if subd's exist
  36. ;
  37. ;    Exit the script
  38. ;
  39. Escape:
  40. Exit:
  41.     SET TEXT N99        ; Reset text attr finally
  42.     DWINDOW CLEAR        ; Clear any scrolling region
  43.     CLEAR            ; Clear entire text window
  44.     EXIT
  45. ; -----------------------------------------------------------------------
  46. ; ----- Subroutine: Init ->  Set initial values from BBSDAT
  47. ;    .. NOTE: S29 returns the file name to use for writes to BBSDAT
  48. ;
  49. Init:
  50.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  51.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for BBS
  52.     S22 = "\BBS"            ; Set to our subdirectory
  53.     S23 = "\BBS\FILES"      ; Set subdir for files
  54.     S24 = "\BBS\MAIL"       ; Set subdir for mail
  55.     S25 = "\BBS\BULLETIN"   ; Set subdir for bulletins
  56.     S26 = ""                ; Doorway command
  57. ;
  58. ;    Replace above values from BBSDAT, if that script exists
  59. ;
  60.     S29 = ""                ; Make value null
  61.     IF ISSC "BBSDAT"        ; If file exists on dft subdir or COM-AND=
  62.        FCALL "BBSDAT"       ; .. execute it
  63.     ELSE
  64.        S10 = "_SCRIPT"      ; Get current script fname
  65.        GOSUB Parse_Fname    ; Extract drive:Subdir from name
  66.        S10 = S10*"\BBSDAT"  ; Make new name
  67.        IF ISSC S10        ; Invoke it if its THERE
  68.           FCALL S10     ; Invoke it
  69.           S29 = S10     ; Save for later
  70.           ENDIF
  71.        ENDIF
  72.     RETURN            ; Done init
  73. ; -----------------------------------------------------------------------
  74. ;    Subroutine: Parse drive:subdirectory from file name
  75. ;
  76. ;    S10 passes fully name        S10 returns drive:subdirectory
  77. ;                    S11 returns file name
  78. ;    N10,N11 are scratch values
  79. ; -----------------------------------------------------------------------
  80. ;
  81. Parse_Fname:
  82.     LENGTH S10 N10            ; Find length of string
  83.     FOR N11 = (N10-1),0,-1        ; Scan backwards through string
  84.         IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
  85.         ENDFOR
  86.     S11 = S10            ; No drive or path
  87.     S10 = ""                        ; Return null drive:path spec
  88.     RETURN
  89. ;
  90. ;    Extract drive and path from name; N11 points to ":" or "\"
  91. ;
  92. PAFN100:
  93.     S11 = S10(N11+1:N10)        ; Extract name portion
  94.     IF STRCMP S10(N11:N11) "\" DEC N11
  95.     S10 = S10(0:N11)        ; Save ":", remove last "\"
  96.     RETURN
  97. ; -----------------------------------------------------------------------
  98. ; ----- Subroutine: Save -> Save values in BBSDAT
  99. ;    .. BBSDAT is placed in dft subdir; create file if need be
  100. ;
  101. Save:
  102.     IF NULL S29        ; If INIT did not set a name
  103.     ;
  104.     ; Construct a file name on the appropriate directory
  105.     ;
  106.        S1 = ""              ; Initialize file name string
  107.        IF NOT ISFIL "BBSDAT"; If not on current subdir
  108.           ENVIRON S1 "COM-AND="; Look for COM-AND= environment var
  109.           IF FOUND        ; If environment variable found
  110.          LENGTH S1 N0    ; Get its length
  111.          N0 = N0-1    ; Point to last char in string
  112.          IF not STRCMP S1(n0:n0) "\"
  113.             N0 = N0+1    ; Point after last char
  114.             CONCAT S1(n0) "\"
  115.             ENDIF
  116.          ENDIF
  117.           ENDIF
  118.        S1 = S1&"BBSDAT"     ; Add the necessary file name
  119.     ELSE S1 = S29        ; Else use name set by INIT
  120.     ;
  121.     ; Open the file, write the file, and close it
  122.     ;
  123.     FOPENO S1 TEXT        ; Open the file name so constructed
  124.     IF NOT SUCCESS
  125.        S0 = "Error opening BBSDAT file: "*S1
  126.        GOSUB Error        ; Report
  127.        RETURN        ; And we're done
  128.        ENDIF
  129.        S29 = "_OFILE"           ; Save file name we opened
  130.        ;
  131.        ; Write values we have as of now
  132.        ;
  133.     WRITE "; --- BBS initialization !" ; Write initial comments
  134.     WRITE ";     Updated "*"_DATE"*", at "*"_TIME"*"!"
  135.     WRITE ";!"                         ; Write initial comments
  136.  
  137.     WRITE "S20=`""*S20&"`"!"    ; Write port and speed
  138.     S0 = S21        ; Copy control string
  139.     PRESERVE S0        ; Make it printable
  140.     WRITE "S21=`""*S0&"`"!" ; Write modem control string
  141.     WRITE "S22=`""*S22&"`"!"; Write BBS subdir
  142.     WRITE "S23=`""*S23&"`"!"; Write BBS files subdir
  143.     WRITE "S24=`""*S24&"`"!"; Write BBS mail subdir
  144.     WRITE "S25=`""*S25&"`"!"; Write BBS bulletin subdir
  145.     WRITE "S26=`""*S26&"`"!"; Write doorway command
  146.     WRITE "FRETURN!^Z "     ; Write end of file
  147.        ;
  148.        ; Close the file and we're done
  149.        ;
  150.     SET FLAG(9) ON        ; Note we did ONE save
  151.     FCLOSEO         ; Close the file
  152.     RETURN            ; And we're done
  153. ; -----------------------------------------------------------------------
  154. ; ----- Error:    Open a window, display a message, and wait for keypress
  155. ;    S0 passes the error message
  156. ;
  157. Error:
  158.     WOPEN 10,10,12,70 (cont) Err_Esc
  159.     ATSAY 10,12 (cont) " Error "
  160.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  161.     ATSAY 12,26 (cont) " Press any key to continue "
  162.     ;
  163.     ;    Wait a keypress
  164.     ;
  165.     KEYGET S0        ; Wait for any key
  166.     WCLOSE
  167. Err_Esc:
  168.     RETURN
  169. ; -----------------------------------------------------------------------
  170. ; ----- Subroutine: ChkSave ->    Save file?
  171. ;
  172. ChkSave:
  173.     IF FLAG(9) RETURN    ; At least one save was performed
  174.     WOPEN 0,0 23,79 (defa) Main_ESC
  175.     ATSAY 0,2 (defa)   " BBS Save "
  176.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  177. CHSA100:
  178.     CLEAR            ; Clear window
  179.     LOCATE 2,2
  180.     MESS " Do you wish to save the current values? (y/n) "
  181.     MESS "──────────────────────────────────── "
  182.     MESS "    Port and speed  is: "*S20
  183.     S0 = S21        ; Copy control string
  184.     PRESERVE S0        ; Make it printable
  185.     MESS "    Modem control   is: "*S0
  186.     MESS "    BBS main subdir is: "*S22
  187.     MESS "    Files subdir    is: "*S23
  188.     MESS "    Mail subdir     is: "*S24
  189.     MESS "    Bulletin subdir is: "*S25
  190.     MESS "    Doorway command is: "*S26
  191.     MESS " "
  192.     MESS "──────────────────────────────────── "
  193.     MESS "Enter y or n (carriage return = n): "
  194. ;
  195. ;    Wait for a keypress
  196. ;
  197.     GET S0 1        ; Wait for it
  198.     IF NULL S0 GOTO CHSA200 ; If c/r, simply return
  199.     SWITCH S0        ; Act according to keyget
  200.       CASE "y"              ; Case insensitive
  201.            GOSUB Save
  202.            GOTO CHSA200
  203.            ENDCASE
  204.       CASE "n"              ; Case insensitive
  205.            GOTO CHSA200
  206.            ENDCASE
  207.       DEFAULT        ; None of the above
  208.            SOUND 100,100    ; Bronx cheer
  209.            ENDCASE
  210.       ENDSWITCH
  211.     GOTO CHSA100        ; Repaint screen and ask again
  212. ;
  213. ;    Exit, closing the window
  214. ;
  215. CHSA200:
  216.     WCLOSE
  217.     RETURN
  218. ; -----------------------------------------------------------------------
  219. ; ----- Subroutine: ChkAll ->  Check for subdir creation req'd
  220. ;
  221. ChkAll:
  222.     WOPEN 10,10 12,70 (cont)
  223.     ATSAY 10,12 (cont)   " BBS Subdirs "
  224.     ATSAY 11,12 (cont) " Checking existance of subdirs... "
  225.     PAUSE 1         ; Make it visible
  226. ;
  227. ;    Test for the existence of all subdirectories
  228. ;
  229.     SET FLAG(0) ON
  230.     FFIRST S22&"\*.*"       ; test for Main subd
  231.     IF SUCCESS SET FLAG(0) OFF
  232.  
  233.     SET FLAG(1) ON
  234.     FFIRST S23&"\*.*"       ; test for File subd
  235.     IF SUCCESS SET FLAG(1) OFF
  236.  
  237.     SET FLAG(2) ON
  238.     FFIRST S24&"\*.*"       ; test for Mail subd
  239.     IF SUCCESS SET FLAG(2) OFF
  240.  
  241.     SET FLAG(3) ON
  242.     FFIRST S25&"\*.*"       ; test for Main subd
  243.     IF SUCCESS SET FLAG(3) OFF
  244.  
  245.     WCLOSE            ; Close window we opened
  246.     IF NOT (FLAG(0) or FLAG(1) or FLAG(2) or FLAG(3)) RETURN
  247. ;
  248. ;    Ask if we're to create subdirs
  249. ;
  250.     WOPEN 0,0 23,79 (defa) Main_ESC
  251.     ATSAY 0,2 (defa)   " BBS Subdirs "
  252.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  253. ;
  254. ;    Display subdirs that do not exist
  255. ;
  256. CHAL100:
  257.     CLEAR            ; Clear window
  258.     LOCATE 2,2
  259.  
  260.     IF FLAG(0) MESS S22&" does not exist"
  261.     IF FLAG(1) MESS S23&" does not exist"
  262.     IF FLAG(2) MESS S24&" does not exist"
  263.     IF FLAG(3) MESS S25&" does not exist"
  264.     MESS " "                ; Blank separator
  265.     MESS " Do you wish to create the missing subdirs? (y/n) "
  266.     MESS "──────────────────────────────────── "
  267.     MESS " "
  268.     MESS "Enter y or n (carriage return = n): "
  269. ;
  270. ;    Wait for a keypress
  271. ;
  272.     GET S0 1        ; Wait for it
  273.     IF NULL S0 GOTO CHAL200 ; If c/r, simply return
  274.     SWITCH S0        ; Act according to keyget
  275.       CASE "y"              ; Case insensitive
  276.            GOSUB CreateSd
  277.            GOTO CHAL200
  278.            ENDCASE
  279.       CASE "n"              ; Case insensitive
  280.            GOTO CHAL200
  281.            ENDCASE
  282.       DEFAULT        ; None of the above
  283.            SOUND 100,100    ; Bronx cheer
  284.            ENDCASE
  285.       ENDSWITCH
  286.     GOTO CHAL100        ; Repaint screen and ask again
  287. ;
  288. ;    Exit, closing the window
  289. ;
  290. CHAL200:
  291.     WCLOSE
  292.     RETURN
  293. ; -----------------------------------------------------------------------
  294. ; ----- Subroutine: Main ->  main menu
  295. ;
  296. Main:
  297.     WOPEN 0,0 23,79 (defa) Main_ESC
  298.     ATSAY 0,2 (defa)   " BBS Setup "
  299.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  300. ;
  301. ;    Paint the menu
  302. ;
  303. Main100:
  304.     CLEAR            ; Clear window
  305.     LOCATE 2,2
  306.     MESS " 1) Identify subdirectories used by BBS;      Do this 1st!!"
  307.     MESS " 2) Create BBS subdirectories and files;      Do this 2nd!!"
  308.     MESS " 3) Identify modem values;                    ..."
  309.     MESS " 4) Identify doorway command (if any).        Finally..."
  310.  
  311.     IF ISSCRIPT "BBMaint" MESS " 5) Invoke maintenance script"
  312.     IF ISSCRIPT "BBS"     MESS " 6) Invoke the BBS"
  313.  
  314.     MESS "──────────────────────────────────── "
  315.     MESS "    Port and speed  is: "*S20
  316.     S0 = S21        ; Copy control string
  317.     PRESERVE S0        ; Make it printable
  318.     MESS "    Modem control   is: "*S0
  319.     MESS "    BBS main subdir is: "*S22
  320.     MESS "    Files subdir    is: "*S23
  321.     MESS "    Mail subdir     is: "*S24
  322.     MESS "    Bulletin subdir is: "*S25
  323.     MESS "    Drop to DOS command is: "
  324.     S0 = S26
  325.     PRESERVE S0        ; Make it printable
  326.     MESS "    "*S0
  327.     MESS "──────────────────────────────────── "
  328.     MESS "BBSMAINT is used to update files once you have SETUP"
  329.     MESS " "
  330.     MESS "──────────────────────────────────── "
  331.     MESS "Select item (carriage return = exit): "
  332. ;
  333. ;    Wait for a keypress
  334. ;
  335.     GET S0 1        ; Wait for it
  336.     SWITCH S0        ; Act according to keyget
  337.       CASE "1"
  338.            GOSUB Subdirs
  339.            ENDCASE
  340.       CASE "2"
  341.            GOSUB ChkAll
  342.            ENDCASE
  343.       CASE "3"
  344.            GOSUB Modem
  345.            ENDCASE
  346.       CASE "4"
  347.            GOSUB DropDOS
  348.            ENDCASE
  349.       CASE "5"
  350.            IF ISSCRIPT "BBMaint"
  351.           WCLOSE          ; Close open window
  352.           SET TEXT N99          ; Reset text attr finally
  353.           DWINDOW CLEAR       ; Clear any scrolling region
  354.           CLEAR           ; Clear entire text window
  355.           EXECUTE "BBMaint"       ; Chain to it
  356.           ENDIF
  357.            ENDCASE
  358.       CASE "6"
  359.            IF ISSCRIPT "BBS"
  360.           WCLOSE          ; Close open window
  361.           SET TEXT N99          ; Reset text attr finally
  362.           DWINDOW CLEAR       ; Clear any scrolling region
  363.           CLEAR           ; Clear entire text window
  364.           EXECUTE "BBS"           ; Chain to it
  365.           ENDIF
  366.            ENDCASE
  367.       CASE "_NULL"          ; c/r alone is exit
  368.            WCLOSE        ; Close window...
  369.            RETURN        ; Leave Main routine
  370.            ENDCASE
  371.       DEFAULT        ; None of the above
  372.            SOUND 100,100    ; Bronx cheer
  373.            ENDCASE
  374.       ENDSWITCH
  375.     GOTO Main100        ; Repaint screen and ask again
  376. ; -----------------------------------------------------------------------
  377. ; ----- Subroutine: Modem ->  modem values
  378. ;
  379. Modem:
  380.     WOPEN 0,0 23,79 (defa) Main_ESC
  381.     ATSAY 0,2 (defa)   " BBS Modem "
  382.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  383. ;
  384. ;    Paint the menu
  385. ;
  386. MODE100:
  387.     CLEAR            ; Clear window
  388.     LOCATE 2,2
  389.     MESS " 1) Identify modem port"
  390.     MESS " 2) Identify modem speed"
  391.     MESS " 3) Identify modem control string"
  392.     MESS "──────────────────────────────────── "
  393.     MESS "    Port and speed  is: "*S20
  394.     S0 = S21        ; Copy control string
  395.     PRESERVE S0        ; Make it printable
  396.     MESS "    Modem control   is: "*S0
  397.     MESS " "
  398.     MESS "──────────────────────────────────── "
  399.     MESS "Select item (carriage return = previous): "
  400. ;
  401. ;    Wait for a keypress
  402. ;
  403.     GET S0 1        ; Wait for it
  404.     SWITCH S0        ; Act according to keyget
  405.       CASE "1"
  406.            GOSUB Modem_Port
  407.            ENDCASE
  408.       CASE "2"
  409.            GOSUB Modem_Speed
  410.            ENDCASE
  411.       CASE "3"
  412.            GOSUB Modem_Control
  413.            ENDCASE
  414.       CASE "_NULL"          ; c/r alone is exit
  415.            WCLOSE        ; Close window...
  416.            RETURN        ; Leave Main routine
  417.            ENDCASE
  418.       DEFAULT        ; None of the above
  419.            SOUND 100,100    ; Bronx cheer
  420.            ENDCASE
  421.       ENDSWITCH
  422.     GOTO MODE100        ; Repaint screen and ask again
  423. ;
  424. ;    Escape during main
  425. ;
  426. Main_Esc:
  427.     S0 = ""                 ; Blank entry
  428.     RETURN            ; And execute it
  429. ;
  430. ; ----- Subroutine: Modem_port -> Set default modem port to use
  431. ;
  432. Modem_Port:
  433.     WOPEN 0,0 23,79 (defa) Main_ESC
  434.     ATSAY 0,2 (defa)   " BBS Port "
  435.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  436.     LOCATE 2,2
  437.  
  438.     MESS "The BBS is currently directed to run on the port: "*S20(0:3)
  439.     MESS " "
  440.     MESS "The BBS may use any port COM1 through COM4.  If you wish to use a port other"
  441.     MESS "than the above, enter it here."
  442.     MESS " "
  443.     MESS "Port (carriage rtn alone accepts): "
  444. ;
  445. ;    Wait for entry, and interpret
  446. ;
  447.     S0 = "    "             ; Default value
  448.     GET S0 4        ; Wait for a char
  449.     IF NULL S0 GOTO MOPOEND ; Nothing entered
  450.     IF NOT FIND S0(0:2) "com" GOTO MOPOERR
  451.     IF S0(3) LT 1 or S0(3) GT 4 GOTO MOPOERR
  452. ;
  453. ;    Save the value
  454. ;
  455.     S20(0:3) = S0        ; Set new value
  456.     GOSUB Save        ; Save the new value
  457. ;
  458. ;    End of window
  459. ;
  460. MOPOEND:
  461.     WCLOSE
  462.     RETURN
  463. ;
  464. ;    Error in input string
  465. ;
  466. MOPOERR:
  467.     SOUND 100,100        ; Bronx cheer
  468.     GOTO Modem_Port     ; And try again
  469. ;
  470. ; ----- Subroutine: Modem_Speed -> Set default modem speed to use
  471. ;
  472. Modem_Speed:
  473.     WOPEN 0,0 23,79 (defa) Main_Esc
  474.     ATSAY 0,2 (defa)   " BBS Speed "
  475.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  476.     LOCATE 2,2
  477.  
  478.     MESS "The BBS currently defaults to wait for call at: "*S20(5:8)*" baud"
  479.     MESS " "
  480.     MESS "The BBS may wait for a call at any rate you wish.  If you wish to use a "
  481.     MESS "speed other than the above, enter it here. Legitimate speeds are: 300,"
  482.     MESS "1200, 2400, 4800, 9600, and 19.2"
  483.     MESS " "
  484.     MESS "Speed (carriage rtn alone accepts): "
  485. ;
  486. ;    Wait for entry, and interpret
  487. ;
  488.     S0 = "    "             ; Default value
  489.     GET S0 4        ; Wait for a char
  490.     IF NULL S0 GOTO MOSPEND ; Nothing entered
  491.     IF NOT FIND "300  300120024004800960019.2" S0(0:2) N0 GOTO MOSPERR
  492.     IF 4*(N0/4) ne N0 GOTO MOSPERR
  493. ;
  494. ;    Save the value
  495. ;
  496.     S20(5:8) = S0        ; Set new value
  497.     GOSUB Save        ; Save the new value
  498. ;
  499. ;    End of window
  500. ;
  501. MOSPEND:
  502.     WCLOSE
  503.     RETURN
  504. ;
  505. ;    Error in input string
  506. ;
  507. MOSPERR:
  508.     SOUND 100,100        ; Bronx cheer
  509.     GOTO Modem_Speed    ; And try again
  510. ;
  511. ; ----- Subroutine: Modem_Control -> Set the modem initialization string to use
  512. ;
  513. Modem_Control:
  514.     WOPEN 0,0 23,79 (defa) Main_Esc
  515.     ATSAY 0,2 (defa)   " BBS Control "
  516.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  517.     LOCATE 2,2
  518.  
  519.     MESS "The BBS currently is set to initialize the modem with: "
  520.     S0 = S21        ; Fetch value
  521.     PRESERVE S0        ; Preserve for printing
  522.     MESS S0         ; Display string
  523.     MESS " "
  524.     MESS "The initialization string must be correct for your modem.  Please refer to "
  525.     MESS "the documentation that came with your modem.  The init string will probably"
  526.     MESS "begin with modem attention (defa 'AT'), MUST enable autoanswer, and will"
  527.     MESS "probably end with a carriage return.  "
  528.     MESS " "
  529.     MESS "Please note: Enter '^^A' through '^^Z' to indicate control chars, '^^^^ for'"
  530.     MESS "a single caret, '!!' for a carriage return (or '^^M') and '!!!!' for a single"
  531.     MESS "exclamation point."
  532.     MESS " "
  533.     MESS "Control string (carriage return accepts): "
  534. ;
  535. ;    Wait for entry, and interpret
  536. ;
  537.     S0 = "    "             ; Default value
  538.     GET S0 50        ; Wait for a char
  539.     IF NULL S0 GOTO MOCOEND ; Nothing entered
  540. ;
  541. ;    Save the value
  542. ;
  543.     S21 = S0        ; Set new value
  544.     GOSUB Save        ; Save the new value
  545. ;
  546. ;    End of window
  547. ;
  548. MOCOEND:
  549.     WCLOSE
  550.     RETURN
  551. ; -----------------------------------------------------------------------
  552. ; ----- Subroutine: CreateSd -> Create subdirectories
  553. ;    .. Flags 0-3 control
  554. ;
  555. CreateSd:
  556.     IF FLAG(0)        ; Main subd does not exist
  557.        S0 = S22        ; Set-up passed parm
  558.        GOSUB Create     ; Attempt to create it
  559.        GOSUB NewUser    ; Create needed file (if d.n.e)
  560.        ENDIF
  561.  
  562.     IF FLAG(1)        ; File subd does not exist
  563.        S0 = S23        ; Set-up passed parm
  564.        GOSUB Create     ; Attempt to create it
  565.        GOSUB NewFile    ; Create needed file (if d.n.e)
  566.        ENDIF
  567.  
  568.     IF FLAG(2)        ; Mail subd does not exist
  569.        S0 = S24        ; Set-up passed parm
  570.        GOSUB Create     ; Attempt to create it
  571.        GOSUB NewMail    ; Create needed file (if d.n.e)
  572.        ENDIF
  573.  
  574.     IF FLAG(3)        ; Bulletin subd does not exist
  575.        S0 = S25        ; Set-up passed parm
  576.        GOSUB Create     ; Attempt to create it
  577.        GOSUB NewBull    ; Create needed file (if d.n.e)
  578.        ENDIF
  579.     RETURN
  580. ;
  581. ; ----- Subroutine: CheckSd -> Create an subdirectories
  582. ;    .. Flags 0-3 control
  583. ;
  584. CheckSd:
  585.     FFIRST S0&"\*.*"        ; Test for existence of subdir
  586.     IF SUCCESS RETURN    ; Return if it exists
  587.     GOSUB Create        ; Attempt to create it
  588.     RETURN
  589. ;
  590. ; ----- Subroutine: Create -> Create a subdirectory
  591. ;    .. S0 passes the subdirectory to create
  592. ;
  593. Create:
  594.     MDIR S0         ; Attempt to create subdir
  595.     IF FAILURE        ; Set-up passed parm
  596.        S0 = "Error creating: "*S0
  597.        GOSUB Error        ; Report the error
  598.        SET SUCCESS OFF    ; Return FAILED condition
  599.        ENDIF
  600.     RETURN
  601. ;
  602. ; ----- Subroutine: NewUser -> Create a new BBS-User file
  603. ;
  604. NewUser:
  605.     IF ISFILE S22&"\BBS-User" RETURN
  606.     FOPENO S22&"\BBS-User" TEXT
  607.     IF NOT SUCCESS        ; Open failed
  608.        S0 = "Error creating: "*S22&"\BBS-User"
  609.        GOSUB Error        ; Report
  610.        RETURN        ; And we're done
  611.        ENDIF
  612.     WRITE "!^Z"             ; Make it empty
  613.     FCLOSEO         ; Done with it
  614.     RETURN
  615. ;
  616. ; ----- Subroutine: NewFile -> Create a new BBS-File file
  617. ;
  618. NewFile:
  619.     IF ISFILE S23&"\BBS-File" RETURN
  620.     FOPENO S23&"\BBS-File" TEXT
  621.     IF NOT SUCCESS        ; Open failed
  622.        S0 = "Error creating: "*S23&"\BBS-File"
  623.        GOSUB Error        ; Report
  624.        RETURN        ; And we're done
  625.        ENDIF
  626.     WRITE "!^Z"             ; Make it empty
  627.     FCLOSEO         ; Done with it
  628.     RETURN
  629. ;
  630. ; ----- Subroutine: NewMail -> Create a new BBS-Mail file
  631. ;
  632. NewMail:
  633.     IF ISFILE S24&"\BBS-Mail" RETURN
  634.     FOPENO S24&"\BBS-Mail" TEXT
  635.     IF NOT SUCCESS        ; Open failed
  636.        S0 = "Error creating: "*S24&"\BBS-Mail"
  637.        GOSUB Error        ; Report
  638.        RETURN        ; And we're done
  639.        ENDIF
  640.     WRITE "!^Z"             ; Make it empty
  641.     FCLOSEO         ; Done with it
  642.     RETURN
  643. ;
  644. ; ----- Subroutine: NewBull -> Create a new BBS-Bull file
  645. ;
  646. NewBull:
  647.     IF ISFILE S25&"\BBS-Bull" RETURN
  648.     FOPENO S25&"\BBS-Bull" TEXT
  649.     IF NOT SUCCESS        ; Open failed
  650.        S0 = "Error creating: "*S25&"\BBS-Bull"
  651.        GOSUB Error        ; Report
  652.        RETURN        ; And we're done
  653.        ENDIF
  654.     WRITE "!^Z"             ; Make it empty
  655.     FCLOSEO         ; Done with it
  656.     RETURN
  657. ; -----------------------------------------------------------------------
  658. ; ----- Subroutine: NewDat ->  Ask if a new BBSDAT file is to be placed?
  659. ;
  660. NewDat:
  661.     IF NULL S29 AND NOT ISSC "BBSDAT" RETURN
  662.     WOPEN 0,0 23,79 (defa) Main_ESC
  663.     ATSAY 0,2 (defa)   " BBS Subdirs "
  664.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  665. NEDA100:
  666.     CLEAR            ; Clear window
  667.     LOCATE 2,2
  668.     MESS "Do you wish to place BBSDAT on the new BBS main subdirectory? (y/n) "
  669.     MESS "──────────────────────────────────── "
  670.     MESS " "
  671.     IF NOT NULL S29
  672.        MESS "BBSDAT is currently: "*S29
  673.     ELSE
  674.        S0 = "_SUBD"&"\BBSDAT"
  675.        IF NOT ISFILE "BBSDAT"
  676.           ENVIRON S0 "COM-AND="; Look for COM-AND= environment var
  677.           IF FOUND        ; If environment variable found
  678.          LENGTH S0 N0    ; Get its length
  679.          N0 = N0-1    ; Point to last char in string
  680.          IF STRCMP S0(n0:n0) "\" S0(n0:n0) = ""
  681.          S0 = S0&"\BBSDAT"
  682.          ENDIF
  683.           ENDIF
  684.        IF ISFILE S0
  685.           MESS "BBSDAT is now: "*S0
  686.        ELSE
  687.           MESS "BBSDAT would be: "*S0
  688.           ENDIF
  689.        ENDIF
  690.     MESS "──────────────────────────────────── "
  691.     MESS " "
  692.     MESS "Enter y or n (carriage return = y): "
  693. ;
  694. ;    Wait for a keypress
  695. ;
  696.     GET S0 1        ; Wait for it
  697.     IF NULL S0 GOTO NEDA200 ; If c/r, simply accept
  698.     SWITCH S0        ; Act according to keyget
  699.       CASE "y"              ; Case insensitive
  700.            GOTO NEDA200
  701.            ENDCASE
  702.       CASE "n"              ; Case insensitive
  703.            WCLOSE        ; DO nothing
  704.            RETURN
  705.            ENDCASE
  706.       DEFAULT        ; None of the above
  707.            SOUND 100,100    ; Bronx cheer
  708.            ENDCASE
  709.       ENDSWITCH
  710.     GOTO NEDA100        ; Repaint screen and ask again
  711. ;
  712. ;    Construct the other subdir names
  713. ;
  714. NEDA200:
  715.     S29 = S22&"\BBSDAT"
  716.     WCLOSE
  717.     RETURN
  718. ; -----------------------------------------------------------------------
  719. ; ----- Subroutine: DftSds ->  Main subdir changed - default the others?
  720. ;
  721. DftSds:
  722.     WOPEN 0,0 23,79 (defa) Main_ESC
  723.     ATSAY 0,2 (defa)   " BBS Subdirs "
  724.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  725. DFSD100:
  726.     CLEAR            ; Clear window
  727.     LOCATE 2,2
  728.     MESS " Do you wish to use the new main subdir as the root for others? (y/n) "
  729.     MESS "──────────────────────────────────── "
  730.     MESS "    BBS main subdir is now:   "*S22
  731.     MESS "    Files subdir WOULD be:    "*S22&"\Files"
  732.     MESS "    Mail subdir WOULD be:     "*S22&"\Mail"
  733.     MESS "    Bulletin subdir WOULD be: "*S22&"\Bulletin"
  734.     MESS " "
  735.     MESS "──────────────────────────────────── "
  736.     MESS "Enter y or n (carriage return = y): "
  737. ;
  738. ;    Wait for a keypress
  739. ;
  740.     GET S0 1        ; Wait for it
  741.     IF NULL S0 GOTO DFSD200 ; If c/r, simply accept
  742.     SWITCH S0        ; Act according to keyget
  743.       CASE "y"              ; Case insensitive
  744.            GOTO DFSD200
  745.            ENDCASE
  746.       CASE "n"              ; Case insensitive
  747.            WCLOSE        ; DO nothing
  748.            RETURN
  749.            ENDCASE
  750.       DEFAULT        ; None of the above
  751.            SOUND 100,100    ; Bronx cheer
  752.            ENDCASE
  753.       ENDSWITCH
  754.     GOTO DFSD100        ; Repaint screen and ask again
  755. ;
  756. ;    Construct the other subdir names
  757. ;
  758. DFSD200:
  759.     S23 = S22&"\Files"
  760.     S24 = S22&"\Mail"
  761.     S25 = S22&"\Bulletin"
  762.     WCLOSE
  763.     RETURN
  764. ; -----------------------------------------------------------------------
  765. ; ----- Subroutine: Subdirs ->    Update subdirectories used by BBS
  766. ;
  767. Subdirs:
  768.     WOPEN 0,0 23,79 (defa) Main_Esc
  769.     ATSAY 0,2 (defa)   " BBS Subdirs "
  770.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  771. SUBD100:
  772.     CLEAR
  773.     LOCATE 2,2
  774.     MESS " 1) Identify BBS main subdir"
  775.     MESS " 2) Identify BBS Files subdir"
  776.     MESS " 3) Identify BBS Mail subdir"
  777.     MESS " 4) Identify BBS Bulletins subdir"
  778.  
  779.     MESS "──────────────────────────────────── "
  780.     MESS "    Main subdir     is: "*S22
  781.     MESS "    Files subdir    is: "*S23
  782.     MESS "    Mail subdir     is: "*S24
  783.     MESS "    Bulletin subdir is: "*S25
  784.     MESS " "
  785.     MESS "──────────────────────────────────── "
  786.     MESS "Select item (carriage return = previous): "
  787. ;
  788. ;    Wait for a keypress
  789. ;
  790.     GET S0 1        ; Wait for it
  791.     SWITCH S0        ; Act according to keyget
  792.       CASE "1"
  793.            GOSUB MainSd
  794.            ENDCASE
  795.       CASE "2"
  796.            GOSUB FileSd
  797.            ENDCASE
  798.       CASE "3"
  799.            GOSUB MailSd
  800.            ENDCASE
  801.       CASE "4"
  802.            GOSUB BullSd
  803.            ENDCASE
  804.       CASE "_NULL"          ; c/r alone is exit
  805.            WCLOSE        ; Close window...
  806.            RETURN        ; Leave Main routine
  807.            ENDCASE
  808.       DEFAULT        ; None of the above
  809.            SOUND 100,100    ; Bronx cheer
  810.            ENDCASE
  811.       ENDSWITCH
  812.     GOTO Subd100        ; Repaint screen and ask again
  813. ;
  814. ; ----- Subroutine: MainSd -> Set the main subdirectory
  815. ;
  816. MainSd:
  817.     WOPEN 0,0 23,79 (defa) Main_Esc
  818.     ATSAY 0,2 (defa)   " BBS Main Subdir "
  819.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  820.     LOCATE 2,2
  821.  
  822.     MESS "The BBS main subdirectory is: "
  823.     MESS S22
  824.     MESS " "
  825.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  826.     MESS "contain at least one file (BBS-User).  The user ID file (BBS-User) residing"
  827.     MESS "there may be updated with from the main menu of this script."
  828.     MESS " "
  829.     MESS "BBS Main subdir (carriage return accepts): "
  830. ;
  831. ;    Wait for entry, and interpret
  832. ;
  833.     S0 = "    "             ; Default value
  834.     GET S0 50        ; Wait for a char
  835.     IF NULL S0 GOTO MASDEND ; Nothing entered
  836.     GOSUB CheckSd        ; Test for create needed
  837.     IF FAILED GOTO MASDEND    ; Skip if create failed
  838. ;
  839. ;    Save the value
  840. ;
  841.     S22 = S0        ; Set new value
  842.     GOSUB NewUser        ; Create needed file (if d.n.e)
  843.     GOSUB DftSds        ; Ask if we're to default the other subdirs
  844.     GOSUB NewDat        ; Ask if a new BBSDAT to be used
  845.     GOSUB Save        ; Save the new value
  846. ;
  847. ;    End of window
  848. ;
  849. MASDEND:
  850.     WCLOSE
  851.     RETURN
  852. ;
  853. ; ----- Subroutine: FileSd -> Set the file subdirectory
  854. ;
  855. FileSd:
  856.     WOPEN 0,0 23,79 (defa) Main_Esc
  857.     ATSAY 0,2 (defa)   " BBS File Subdir "
  858.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  859.     LOCATE 2,2
  860.  
  861.     MESS "The BBS file subdirectory is: "
  862.     MESS S23
  863.     MESS " "
  864.     MESS "The main subdirectory must exist (it will be created if need be), and will "
  865.     MESS "contain at least one file (BBS-File).  The file list (BBS-File) residing"
  866.     MESS "there may be updated with from the main menu of this script."
  867.     MESS " "
  868.     MESS "BBS File subdir (carriage return accepts): "
  869. ;
  870. ;    Wait for entry, and interpret
  871. ;
  872.     S0 = "    "             ; Default value
  873.     GET S0 50        ; Wait for a char
  874.     IF NULL S0 GOTO FISDEND ; Nothing entered
  875.     GOSUB CheckSd        ; Test for create needed
  876.     IF FAILED GOTO FISDEND    ; Skip if create failed
  877.     GOSUB NewFile        ; Create needed file (if d.n.e)
  878. ;
  879. ;    Save the value
  880. ;
  881.     S23 = S0        ; Set new value
  882.     GOSUB Save        ; Save the new value
  883. ;
  884. ;    End of window
  885. ;
  886. FISDEND:
  887.     WCLOSE
  888.     RETURN
  889. ;
  890. ; ----- Subroutine: MailSd -> Set the mail subdirectory
  891. ;
  892. MailSd:
  893.     WOPEN 0,0 23,79 (defa) Main_Esc
  894.     ATSAY 0,2 (defa)   " BBS Mail Subdir "
  895.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  896.     LOCATE 2,2
  897.  
  898.     MESS "The BBS Mail subdirectory is: "
  899.     MESS S24
  900.     MESS " "
  901.     MESS "The Mail subdirectory must exist (it will be created if need be), and will "
  902.     MESS "contain at least one file (BBS-Mail).  The user ID file (BBS-Mail) residing"
  903.     MESS "there may be updated with from the main menu of this script."
  904.     MESS " "
  905.     MESS "BBS Mail subdir (carriage return accepts): "
  906. ;
  907. ;    Wait for entry, and interpret
  908. ;
  909.     S0 = "    "             ; Default value
  910.     GET S0 50        ; Wait for a char
  911.     IF NULL S0 GOTO MLSDEND ; Nothing entered
  912.     GOSUB CheckSd        ; Test for create needed
  913.     IF FAILED GOTO MLSDEND    ; Skip if create failed
  914.     GOSUB NewMail        ; Create needed file (if d.n.e)
  915. ;
  916. ;    Save the value
  917. ;
  918.     S24 = S0        ; Set new value
  919.     GOSUB Save        ; Save the new value
  920. ;
  921. ;    End of window
  922. ;
  923. MLSDEND:
  924.     WCLOSE
  925.     RETURN
  926. ;
  927. ; ----- Subroutine: BullSd -> Set the bulletin subdirectory
  928. ;
  929. BullSd:
  930.     WOPEN 0,0 23,79 (defa) Main_Esc
  931.     ATSAY 0,2 (defa)   " BBS Bulletin Subdir "
  932.     ATSAY 23,25 (defa) " Press ESC to cancel BBSETUP "
  933.     LOCATE 2,2
  934.  
  935.     MESS "The BBS bulletin subdirectory is: "
  936.     MESS S25
  937.     MESS " "
  938.     MESS "The Bulletin subdirectory must exist (it will be created if need be), and will "
  939.     MESS "contain at least one file (BBS-Bull).  The user ID file (BBS-Bull) residing"
  940.     MESS "there may be updated with from the main menu of this script."
  941.     MESS " "
  942.     MESS "BBS Bulletin subdir (carriage return accepts): "
  943. ;
  944. ;    Wait for entry, and interpret
  945. ;
  946.     S0 = "    "             ; Default value
  947.     GET S0 50        ; Wait for a char
  948.     IF NULL S0 GOTO BUSDEND ; Nothing entered
  949.     GOSUB CheckSd        ; Test for create needed
  950.     IF FAILED GOTO BUSDEND    ; Skip if create failed
  951.     GOSUB NewBull        ; Create needed file (if d.n.e)
  952. ;
  953. ;    Save the value
  954. ;
  955.     S25 = S0        ; Set new value
  956.     GOSUB Save        ; Save the new value
  957. ;
  958. ;    End of window
  959. ;
  960. BUSDEND:
  961.     WCLOSE
  962.     RETURN
  963. ; -----------------------------------------------------------------------
  964. ; ----- Subroutine: DropDOS -> Define the DROP-to-DOS mode command
  965. ;
  966. DropDOS:
  967.     WOPEN 0,0 23,79 (defa) Main_Esc
  968.     ATSAY 0,2 (defa)   " HOST DropDOS command "
  969.     ATSAY 23,25 (defa) " Press ESC to cancel HOSETUP "
  970.     LOCATE 2,2
  971.  
  972.     MESS "The Drop-to-DOS command currently is: "
  973.     S0 = S26
  974.     PRESERVE S0        ; Make it printable
  975.     MESS S0
  976.     MESS " "
  977.     MESS "The Drop-To-DOS command must execute a function such as DOORWAY for a"
  978.     MESS "drop into DOS.  This feature is not available if the command here is"
  979.     MESS "set null.  If this feature IS not null, the command here will be built"
  980.     MESS "into a temporary batch file and executed on request (DOS passworded)."
  981.     MESS " "
  982.     MESS "HOST Drop-to-DOS command (you MUST enter new value): ^M^J"
  983. ;
  984. ;    Wait for entry, and interpret
  985. ;
  986.     S0 = "    "             ; Default value
  987.     GET S0 70        ; Wait for entry
  988. ;
  989. ;    Save the value
  990. ;
  991.     S26 = S0        ; Set new value
  992.     GOSUB Save        ; Save the new value
  993. ;
  994. ;    End of window
  995. ;
  996. DRDOEND:
  997.     WCLOSE
  998.     RETURN
  999.